use "JLC_citationsdata.dta"
ssc install estout, replace

***** LOGGED DV
gen SC_DV=SC_incites+SC_pos+SC_neut
gen CA_DV=CA_incites+CA_pos+CA_neut
gen DC_DV=DC_incites+DC_pos+DC_neut
gen log_SC=log(SC_DV+1)
gen log_CA=log(CA_DV+1)
gen log_DC=log(DC_DV+1)

*TABLE A.1: Main results with and without controls
eststo clear
xtgee log_SC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
gen fullmodelsample=e(sample)
eststo: xtgee
xtgee log_CA i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_DC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_SC SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if fullmodelsample==1, corr(ar 1) vce(robust) 
eststo: xtgee
xtgee log_CA  SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if fullmodelsample==1, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_DC SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if fullmodelsample==1, corr(ar 1) vce(robust)
eststo: xtgee
esttab, drop(*.age2 *.issueArea) se(3) b(3) label 


*FIGURE A.1: Age Plots
coefplot est1, keep(*.age2) vertical coeflabels(*.age2= " ")xtitle(Age) ytitle(Citations) title("Supreme Court") 
coefplot est2, keep(*.age2) vertical coeflabels(*.age2= " ") xtitle(Age) ytitle(Citations) title("Courts of Appeals")
coefplot est3, keep(*.age2) vertical coeflabels(*.age2= " ") xtitle(Age) ytitle(Citations) title("District Courts")

*TABLE A.2: Linear model
eststo clear
regress log_SC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, cluster(uslexis)
eststo: regress
regress log_CA i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, cluster(uslexis)
eststo: regress
regress log_DC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, cluster(uslexis)
eststo: regress
esttab, drop(*.age2 *.issueArea) se(3) b(3) label 

*TABLE A.3: Include lagged cites
eststo clear
xtgee log_SC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes l.log_SC, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_CA i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes l.log_CA, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_DC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes l.log_DC, corr(ar 1) vce(robust)
eststo: xtgee
esttab, drop(*.age2 *.issueArea) se(3) b(3) label 

*TABLE A.4: Dummy/Counts of citation
gen dummy_SC_DV=(SC_DV>0)
eststo clear
xtgee dummy_sc_incites_year_final i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, family(binomial) link(logit) corr(ar 1) vce(robust)
eststo: xtgee
xtgee SC_DV i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, family(nbinomial) corr(ar 1) vce(robust)
eststo: xtgee
xtgee CA_DV i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, family(nbinomial) corr(ar 1) vce(robust) iterate(1000)
eststo: xtgee
xtgee DC_DV i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, family(nbinomial) corr(ar 1) vce(robust)
eststo: xtgee
esttab, drop(*.age2 *.issueArea) se(3) b(3) label 

*TABLE A.5: Age functional form
eststo clear
xtgee log_SC age4d1 age4d2 age4d3 age4d4 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_CA ageCAd1 ageCAd2 ageCAd3 ageCAd4 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
esttab, drop(*.issueArea) se(3) b(3) label 

*TABLE A.6: Ranked opinion writer ideology
generate absrank=abs(rank)
eststo clear
xtgee log_SC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed absrank majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_CA i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed absrank majVotes if age2>0,corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_DC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed absrank majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
esttab, drop(*.age2 *.issueArea) se(3) b(3) label 

*TABLE A.7: Ideological congruence between Supreme Court and precedent
eststo clear
xtgee log_SC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_lib SC_decision_con PrecedentMedian disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_CA i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_lib SC_decision_con PrecedentMedian disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_DC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_lib SC_decision_con PrecedentMedian disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_SC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_lib SC_decision_con##c.PrecedentMedian disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_CA i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_lib SC_decision_con##c.PrecedentMedian disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_DC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_lib SC_decision_con##c.PrecedentMedian disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
esttab, drop(*.age2 *.issueArea) se(3) b(3) label 

*TABLE A.8:  Table 4 replication with total citations
gen log_SCt=log(SC_total+1)
gen log_CAt=log(CA_total+1)
gen log_DCt=log(DC_total+1)
eststo clear
xtgee log_SCt i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_CAt i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_DCt i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
esttab, drop(*.age2 *.issueArea) se(3) b(3) label 

*TABLE A.9: Table 5 replication with total citations
eststo clear
xtgee log_SCt i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_lib SC_decision_con disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_CAt i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_lib SC_decision_con disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_DCt i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_lib SC_decision_con disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust) 
eststo: xtgee
xtgee log_SCt i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_con SC_decision_lib##disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_CAt i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_con SC_decision_lib##disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_DCt i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_con SC_decision_lib##disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
esttab, drop(*.age2 *.issueArea) se(3) b(3) label 

*TABLE A.10: Table 6 replication with total citations
eststo clear
xtgee log_CAt i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol CAalign disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_DCt i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol DCalign disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
esttab, drop(*.age2 *.issueArea) se(3) b(3) label 

*TABLE A.11: Table 7 replication with total citations
eststo clear
xtgee log_DCt i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_ideol CAalign disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
esttab, drop(*.age2 *.issueArea) se(3) b(3) label 

*TABLE A.12: Table 5 including lower court ideology
eststo clear
xtgee log_SC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_lib SC_decision_con disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_CA i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_lib SC_decision_con disagree dist_PrecMedCitMed dist_OWPrecMed majVotes CAalign if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_DC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_lib SC_decision_con disagree dist_PrecMedCitMed dist_OWPrecMed majVotes DCalign if age2>0, corr(ar 1) vce(robust) 
eststo: xtgee
xtgee log_SC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_con SC_decision_lib##disagree dist_PrecMedCitMed dist_OWPrecMed majVotes if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_CA i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_con SC_decision_lib##disagree dist_PrecMedCitMed dist_OWPrecMed majVotes CAalign if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
xtgee log_DC i.age2 i.issueArea prev_overrule_1 complexity amiciz maj_total_length sep_total_length footnote_ratio running_total_opinions pauth_num_lag phub_num_lag original SC_decision_con SC_decision_lib##disagree dist_PrecMedCitMed dist_OWPrecMed majVotes DCalign if age2>0, corr(ar 1) vce(robust)
eststo: xtgee
esttab, drop(*.age2 *.issueArea) se(3) b(3) label 
